<?php

set_include_path('.' . 
	PATH_SEPARATOR . 'library/' .
	PATH_SEPARATOR . 'library/common/' .
	PATH_SEPARATOR . 'application/default/models/' .
	PATH_SEPARATOR . 'library/Zend/library/' .
	PATH_SEPARATOR . get_include_path()
);

require_once('Zend/Controller/Front.php');
require_once('Zend/Loader/Autoloader.php');

$loader = Zend_Loader_Autoloader::getInstance();
$loader->setFallbackAutoloader(true);

/**
 * Banco de dados.
 */

$config = new Zend_Config_Ini('application/config.ini', null);

Zend_Registry::set('config', $config);

$db = Zend_Db::factory($config->producao->db->adapter, $config->producao->db->config->toArray());

$db->getProfiler()->setEnabled(true);

Zend_Db_Table::setDefaultAdapter($db);

$profiler = new Zend_Db_Profiler_Firebug('todas as querys');

$profiler->setEnabled(true);
$db->setProfiler($profiler);

/**
 * Carrega a Classe com métodos comuns. 
 */
Zend_Loader::loadClass('AppBaseController', 'library/common/');

/**
 * Setup controller
 */

$controller = Zend_Controller_Front::getInstance();
$controller->setControllerDirectory(array("default" => 'application/default/controllers'));
$controller->throwExceptions(true); // should be turned on in development time 

/**
 * run!
 */ 

Zend_Layout::startMvc();

$controller->dispatch();